using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace DemoApp.DataAccess 
{
  public partial class FavoriteEntityConfiguration 
    : EntityTypeConfiguration<Favorite>
  {
    public FavoriteEntityConfiguration()
    {
      HasEntitySetName(@"Favorites");
      Map(map => {
        map.ToTable(@"Favorites");
      });
      HasKey(e => new { e.UserId, e.SubjectId });
 

      Property(e => e.Vote);
 

      HasRequired(e => e.User) 
        .WithMany()
        .HasForeignKey(e => new { e.UserId })
        .WillCascadeOnDelete(false);

      HasRequired(e => e.Subject) 
        .WithMany()
        .HasForeignKey(e => new { e.SubjectId })
        .WillCascadeOnDelete(false);

      HasMany(e => e.SuperFavorites)
        .WithMany(e => e.SubFavorites);
    }
  }
}
